<template>
  <view class="FaQ">
    <view class="main">
		<view class="list" v-for="(item, index) in initData" :key="index" @click="godetail(item.id)">
		   {{item.title}}
		  <uni-icons type="arrowright" size="24" color="#999" />
		</view>
      
	  <view v-show="initData.length==0" class="notavailable">
	  	<image src="../../../static/img/notavailable.png" mode="widthFix"></image>
	  	<view class="nottext">暂时没有数据</view>
	  </view>
    </view>
	<view class="pagination">
		<view class="left" :class="{ forbid: paging.page == 1 }" @click="prev">
			<uni-icons type="arrowleft" size="20" color="#fff" class="icons" />
			上一页
		</view>
		<view class="center">{{ paging.page }}/{{ paging.total }}</view>
		<view class="right" :class="{ forbid: paging.page == paging.total }" @click="next">
			下一页
			<uni-icons type="arrowright" size="20" color="#fff" class="icons" />
		</view>
	</view>
  </view>
</template>
<script>
import { uniIcons } from '@dcloudio/uni-ui';
import help from '../../../servers/my/help.js';
export default {
	components: { uniIcons },
	data() {
		return {
			compile: false,
			initData:'',
			type:'',
			is_go_top: false,
			is_all: false,
			paging: {
				page: 1,
				total: 10
			}
		};
	},
	mounted() {
		this.type = uni.getStorageSync('myhelptype')||this.$route.query.myhelptype
		if(this.type){
			this.getData()
		}
	},
	methods: {
		getData(){
			var obj={type:this.type,currentPage:this.paging.page, pageSize: 10};
			help.findListByType(obj)
				.then(res => {
					if(res.code==200){
						this.initData=res.data.records;
						this.paging.total=Math.ceil(res.data.total/res.data.size); 
						console.log(this.initData)
					}else{
						uni.showToast({
						    title: '数据加载失败，请联系管理员'
						});
					}
				})
				.catch(err => {
					console.log(new Error('请检查网络后重试'));
				});
		},
		go_type(type){
			
			this.commonality.route_baling('/pages/shop/my/faq','myhelptype',e)
		},
		godetail(id){
			var obj={type:this.type,currentPage:this.paging.page, pageSize: 10};
			uni.navigateTo({
				url:'./helpdetail?id='+id+'&obj='+JSON.stringify(obj)
			})
		},
		next() {
			if (this.paging.page < this.paging.total) {
				this.paging.page += 1;
					this.getData();
			}
		},
		prev() {
			if (this.paging.page > 1) {
				this.paging.page -= 1;
					this.getData();
			}
		}
		
	}
};
</script>
<style lang="less" scoped>
.FaQ {
  height: 100%;
  background: #fff;
  padding-bottom: 50rpx;
  .main {
	  padding: 0 12px 0 15px;
	  .list {
	    padding: 16px 0;
	    font-size: 16px;
		color: #666;
	    border-bottom: 1rpx solid #e1e1e1; /*no*/
	    .uni-icons {
	      float: right;
	    }
	  }
    .ul {
      padding: 0 20rpx;
      .li {
        font-size: 16px;
        .title {
          color: #bd3c8c;
          padding: 35rpx 0 15rpx;
        }
        .msg {
          line-height: 44rpx;
        }
      }
    }
  }
}
</style>
